"use client";
import { Create, useForm } from "@refinedev/antd";
import { useParsed } from "@refinedev/core";
import { Form, Input, Select } from "antd";
import MenuSelector from "@/components/menu-selector";

export default function RoleCreate() {
  const { id } = useParsed();
  const { formProps, saveButtonProps } = useForm({
    resource: "system/role",
    id: id
  });
  
  return (
    <Create saveButtonProps={saveButtonProps}>
      <Form {...formProps} layout="vertical">
        <Form.Item name="role_name" label="角色名称" rules={[{ required: true }]}> 
          <Input placeholder="请输入角色名称" /> 
        </Form.Item>
        <Form.Item name="role_key" label="权限字符串" rules={[{ required: true }]}> 
          <Input placeholder="请输入权限字符串" /> 
        </Form.Item>
        <Form.Item name="role_sort" label="显示顺序" rules={[{ required: true }]}>
          <Input type="number" placeholder="请输入显示顺序" />
        </Form.Item>
        <Form.Item name="status" label="状态" rules={[{ required: true }]}>
          <Select placeholder="请选择状态">
            <Select.Option value="0">正常</Select.Option>
            <Select.Option value="1">停用</Select.Option>
          </Select>
        </Form.Item>
        <Form.Item name="menu_ids" label="菜单权限">
          <MenuSelector />
        </Form.Item>
        <Form.Item name="remark" label="备注"> 
          <Input.TextArea rows={2} placeholder="请输入备注信息" /> 
        </Form.Item>
      </Form>
    </Create>
  );
} 